package com.iwdnb.gkgz.port.service;

import java.math.BigDecimal;

import com.alibaba.fastjson.JSONObject;

import com.iwdnb.gkgz.common.model.dto.Stock;
import com.iwdnb.gkgz.infrastructure.dao.repo.StockRepository;
import com.iwdnb.ssww.port.script.impl.MetaSaveObjectServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StrategyTradeSaveObjectService extends MetaSaveObjectServiceImpl {

    @Autowired
    private StockRepository stockRepository;

    @Override
    public void beforeSaveObject(String objectCode, JSONObject params) {
        String code = params.getString("code");
        Stock stock = stockRepository.findByCode(code);
        params.put("name", stock.getName());
        params.put("status", "buy");
        params.put("rangeMaxPrice", stock.getPrice());
        params.put("realtimePrice", stock.getPrice());
        params.put("realtimeRate", BigDecimal.ZERO);
        params.put("backFlag", "n");
    }

}
